<?php

class LoginAction extends Action{

        public function index(){
                $this->display();
        }

        public function verify(){
            import('ORG.Util.Image');
            Image::buildImageVerify();
        }
        
        public function login(){
			/*
            if(!$this->is_post){
                halt('页面不存在');
            }
			*/
			
            if ($_SESSION['verify'] != md5($_POST['verify'])) {
                $this->error('验证码错误');
            }

			$name = $this->_post('uname');
			$pwd = $this->_post('pwd', 'md5');
			$where = array('username' => $name);
			$user = M('admin')->where($where)->find();

			if (!$user || $user['password'] != $pwd) {
					$this->error('用户名或密码错误');
			}

			if ($user['lock']) {
					$this->error('管理员被锁定');
			}
			
			session('username', $user['username']);
			session('uid', $user['id']);
			redirect(U('Index/index'));
			
			}
        
        
}
?>